import request from '/@/utils/request'

export function api(tablename: any, functions: any, method: any, params: any) {
  const res = request({
    url: `/${tablename}/${functions}`,
    method: method ? method : 'get',
    params,
  })
  console.log('api', res)
  return res
}

export function api_getLast(tablename: any, params: any) {
  const res = request({
    url: `/${tablename}/getLast`,
    method: 'get',
    params,
  })
  // console.log('api_getall', res)
  return res
}

export function api_saas_detail(tablename: any, params: any) {
  const res = request({
    url: `/${tablename}/saas_detail`,
    method: 'get',
    params,
  })
  console.log('api_saas_detail', res)
  return res
}

export function api_download(tablename: any, params: any) {
  const res = request({
    url: `/${tablename}/download_center`,
    method: 'get',
    params,
  })
  console.log('api_download', res)
  return res
}

export function api_upload(tablename: any, params: any) {
  const res = request({
    url: `/${tablename}/upload`,
    method: 'get',
    params,
  })
  console.log('api_upload', res)
  return res
}

export function api_truncate(tablename: any, params: any) {
  const res = request({
    url: `/${tablename}/truncate`,
    method: 'get',
    params,
  })
  console.log('api_truncate', res)
  return res
}

export function api_getall(tablename: any, params: any) {
  const res = request({
    url: `/${tablename}/getall`,
    method: 'get',
    params,
  })
  console.log('api_getall', res)
  return res
}

export function api_datalist(tablename: any, params: any) {
  const res = request({
    url: `/${tablename}/datalist`,
    method: 'get',
    params,
  })
  console.log('api_datalist', res)
  return res
}

export function api_datalist_ori(tablename: any, params: any, fields: any) {
  params.fields = fields
  const res = request({
    url: `/${tablename}/datalist`,
    method: 'post',
    params,
  })
  console.log('api_datalist_ori', res)
  return res
}

//查询回收站
export function api_recycle(tablename: any, params: any) {
  return request({
    url: `/${tablename}/datalist_recycle`,
    method: 'get',
    params,
  })
}
//恢复数据
export function api_recovery(tablename: any, params: any) {
  return request({
    url: `/${tablename}/recovery`,
    method: 'get',
    params,
  })
}
//彻底删除
export function api_com_del(tablename: any, params: any) {
  return request({
    url: `/${tablename}/com_del`,
    method: 'get',
    params,
  })
}
//批量恢复
export function api_recoveryChecked(tablename: any, data: any) {
  const res = request({
    url: `/${tablename}/recoveryChecked`,
    method: 'post',
    data,
  })
  return res
}

//批量彻底删除
export function api_com_delChecked(tablename: any, data: any) {
  return request({
    url: `/${tablename}/com_delChecked`,
    method: 'post',
    data,
  })
}

export function api_getLoad(tablename: any, data: any) {
  const res = request({
    url: `/${tablename}/getLoad`,
    method: 'post',
    data,
  })
  console.log(res)
  return res
}
export function api_save(tablename: any, data: any) {
  const res = request({
    url: `/${tablename}/save`,
    method: 'post',
    data,
  })
  console.log(res)
  return res
}
export function api_del(tablename: any, data: any) {
  return request({
    url: `/${tablename}/del`,
    method: 'post',
    data,
  })
}
export function api_delChecked(tablename: any, data: any) {
  console.log(data)
  return request({
    url: `/${tablename}/delChecked`,
    method: 'post',
    data,
  })
}
export function api_detail(tablename: any, data: any) {
  return request({
    url: `/${tablename}/detail`,
    method: 'post',
    data,
  })
}

export function api_changeStatus(tablename: any, data: any) {
  return request({
    url: `/${tablename}/changeStatus`,
    method: 'post',
    data,
  })
}

export function api_exportsChecked(tablename: any, params: any) {
  const res = request({
    url: `/${tablename}/exportsChecked`,
    method: 'post',
    params,
  })
  return res
}
export function api_exports(tablename: any, params: any) {
  const res = request({
    url: `/${tablename}/exports`,
    method: 'post',
    params,
  })
  return res
}
